<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加医生</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" media="all"/>
<link rel="stylesheet" href="/static/css/public.css" media="all" />
<link rel="stylesheet" href="/static/css/repair.css" media="all" />
<body class="childrenBody">
<form class="layui-form layui-row layui-col-space10">
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label"><span class="required">*</span>患者姓名</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input patName" AUTOCOMPLETE="off" name="patName" lay-verify="required" placeholder="请输入患者姓名">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label"><span class="required">*</span>身份证号</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input patId" name="patId" AUTOCOMPLETE="off" lay-verify="required" placeholder="请为该患者身份证号">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label"><span class="required">*</span>患者性别</label>
                    <div class="layui-input-block">
                        <input type="radio" class="layui-input patSex" AUTOCOMPLETE="off" name="patSex" value="男" title="男">
                        <input type="radio" class="layui-input patSex" AUTOCOMPLETE="off" name="patSex" value="女" title="女">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label"><span class="required">*</span>联系方式</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input patTel" name="patTel" AUTOCOMPLETE="off" lay-verify="required|phone" placeholder="请输入该患者的手机号码">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label"><span class="required">*</span>出生年月</label>
                    <div class="layui-input-block">
                        <input  class="layui-input patDate" name="patDate" id="patDate" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label"><span class="required">*</span>地址</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input patAddress" name="patAddress" AUTOCOMPLETE="off" lay-verify="required" placeholder="请输入该患者的现居地址">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <label class="layui-form-label"><span class="required">*</span>初始密码</label>
                    <div class="layui-input-block">
                        <input type="password" class="layui-input docPassword" name="docPassword" AUTOCOMPLETE="off" lay-verify="required" placeholder="请为该患者初始化密码">
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-col-md4 layui-col-md-offset4 layui-col-xs12">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12 layui-col-xs7">
                <div class="layui-form-item magt3">
                    <div class="layui-input-block">
                        <a class="layui-btn layui-btn-sm" lay-filter="addPatient" lay-submit><i class="layui-icon">&#xe605;</i>添加患者</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</form>
</body>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form','jquery','element','laydate'],function () {
        var form = layui.form,
            $ = layui.jquery,
            element = layui.element,
            laydate = layui.laydate

        laydate.render({
            elem:'#patDate'
        });


        /**
         * 添加患者
         */
        form.on('submit(addPatient)',function (obj) {
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            var data = obj.field;
            /**
             * 请求后台
             */
            $.ajax({
                type:'POST',
                url:'/admin/addPatient',
                data:JSON.stringify(data),
                dataType:'json',
                contentType:'application/json',
                success:function (res) {
                    /**
                     * 添加成功后回调
                     **/
                    setTimeout(function(){
                        top.layer.close(index);
                        top.layer.msg("添加成功！");
                        layer.closeAll("iframe");
                        //刷新父页面
                        parent.location.reload();
                    },500);
                    return false;
                }
            });

        })
    });
</script>
</html>